package com.cw.jeeyt.service.converter.security;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.security.SecurityOperateLogBo;
import com.cw.jeeyt.dao.model.security.SecurityOperateLogDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 操作日志转换类
 *
 * @author chenw
 * @date 2019-03-10 13:01:34
 */
public class SecurityOperateLogConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static SecurityOperateLogBo do2Bo(SecurityOperateLogDo model) {
        if (model == null) {
            return null;
        }
        SecurityOperateLogBo bo = new SecurityOperateLogBo();
        bo.setId(model.getId());
        bo.setUserId(model.getUserId());
        bo.setUserName(model.getUserName());
        bo.setOperateType(model.getOperateType());
        bo.setOperateTime(model.getOperateTime());
        bo.setOperateModule(model.getOperateModule());
        bo.setLogDate(model.getLogDate());
        bo.setLogDes(model.getLogDes());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static SecurityOperateLogDo bo2Do(SecurityOperateLogBo bo) {
        if (bo == null) {
            return null;
        }
        SecurityOperateLogDo model = new SecurityOperateLogDo();
        model.setId(bo.getId());
        model.setUserId(bo.getUserId());
        model.setUserName(bo.getUserName());
        model.setOperateType(bo.getOperateType());
        model.setOperateTime(bo.getOperateTime());
        model.setOperateModule(bo.getOperateModule());
        model.setLogDate(bo.getLogDate());
        model.setLogDes(bo.getLogDes());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<SecurityOperateLogBo> doList2BoList(List<SecurityOperateLogDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SecurityOperateLogConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<SecurityOperateLogDo> boList2DoList(List<SecurityOperateLogBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SecurityOperateLogConverter::bo2Do));
    }
}